********************************************************************************
* Replication Do File for Main Results:
* Benjamin Smith and David Waldner (2020) 
* "Endogenous Sovereignty and Survivorship Bias in Comparative Politics"

* Data generated using Stata 16 

********************************************************************************

use "Smith.Waldner.2020.Replication.dta", clear

********************************************************************************
* TABLE 1: Survival Models on the Impact of Oil and Gas Revenues on 
* Authoritarian Breakdown with Geddes Autocratic Spell 
********************************************************************************

stset dura_2, failure(geddes_fail) id(ccode)

* Model 1 
stcox cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980, nolog ///
nohr efron robust cluster(ccode) strata(geddes_spell_new) 
eststo m1 
estat phtest, detail

* Model 2  
stcox cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post1980 ///
c.lnrentlevnew#i.post1980, nolog nohr efron robust cluster(ccode) ///
strata(geddes_spell_new) 
eststo m2
estat phtest, detail

* Model 3 
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980 , nolog ///
nohr efron robust cluster(ccode) strata(geddes_spell_new) 
eststo m3
estat phtest, detail

* Model 4 
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980 ///
c.log_oilgas#i.post1980, nolog nohr efron robust cluster(ccode) ///
strata(geddes_spell_new) 
eststo m4
estat phtest, detail

* Model 5
stcox cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post1980, nolog nohr efron robust cluster(ccode) strata(geddes_spell_new) 
eststo m5
estat phtest, detail

* Model 6
stcox cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post1980 c.log_rentlevnew_counter#i.post1980, nolog nohr efron robust ///
cluster(ccode) strata(geddes_spell_new) 
eststo m6
estat phtest, detail

* Model 7
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter ///
i.post1980, nolog nohr efron robust cluster(ccode) strata(geddes_spell_new) 
eststo m7
estat phtest, detail

* Model 8 
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter i.post1980 ///
c.log_oilgas_counter#i.post1980, nolog nohr efron robust cluster(ccode) ///
strata(geddes_spell_new) 
eststo m8
estat phtest, detail

estout m1 m2 m3 m4 m5 m6 m7 m8 using smith.walder.table1.xls, replace ///
cells(b(star fmt(3)) se(par(`"="("'`")""'))) stats(N aic bic) /// 
starlevels(* 0.10 ** 0.05 *** 0.01) 


********************************************************************************
* FIGURE 6. Predicted Survival Probabilities of Authoritarian Regimes 
* by Rent Leverage (Model 1) and Oil & Gas Income (Model 3) in 1955-2010 with
* Geddes Autocratic Spell
********************************************************************************

* Model 1 
stcox cgdpo mad_growth neighbor_cg_democracy c.lnrentlevnew i.post198, nolog ///
nohr efron robust cluster(ccode) basesurv(base1)

gen sd1 = base1^exp(_b[lnrentlevnew]*(-2.4756073))

line base1 sd1 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Rent Leverage Mean+2SD"))

* Model 3
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas i.post1980, nolog ///
nohr efron robust cluster(ccode) basesurv(base3)

gen sd3 = base3^exp(_b[log_oilgas]*(11.427869))

line base3 sd3 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Oil&Gas Income Mean+2SD"))


********************************************************************************
* FIGURE 7. Predicted Survival Probabilities of Authoritarian Regimes 
* by Counterfactual Rent Leverage (Model 5) and Oil & Gas Income (Model 7) 
* in 1955-2010 with Geddes Autocratic Spell
********************************************************************************

* Model 5
stcox cgdpo mad_growth neighbor_cg_democracy c.log_rentlevnew_counter ///
i.post198, nolog nohr efron robust cluster(ccode) basesurv(base5)

gen sd5 = base5^exp(_b[log_rentlevnew_counter]*(-.52681921))

line base5 sd5 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Rent Leverage Counterfactual Mean+2SD") size(small))

* Model 7
stcox cgdpo mad_growth neighbor_cg_democracy c.log_oilgas_counter ///
i.post1980, nolog nohr efron robust cluster(ccode) basesurv(base7)

gen sd7 = base7^exp(_b[log_oilgas_counter]*(10.758885))

line base7 sd7 _t, sort ytitle(Survival Probabilities) ylabel(0 (0.1) 1) ///
lwidth(medium medium) xtitle(Duration) ///
legend(lab(1 "Baseline") lab(2 "Logged Oil & Gas Income Counterfactual Mean+2SD") size(small))
